package twitorg;

import java.io.IOException;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import twinb.Twinb;

public class NewTweetServlet extends HttpServlet
{
    public void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException
    {
        String uname = (String) req.getSession().getAttribute("username");
        if (uname == null || uname.isEmpty())
            return;
        String text = (String) req.getParameter("text");
        if (text != null && !text.isEmpty())
        {
            Twinb tw = Twinb.get(uname);
            tw.newStatus(text);
            resp.getOutputStream().println("done.");
        }
    }
}
